package de.szut.ita13.sommerfeld.loganalyser;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class Resource {

	private String resource;
	private int counter;
	
	public Resource(String resource, int counter) {
		this.resource = resource;
		this.counter = counter;
	}

	public String getResource() {
		return resource;
	}

	public void setResource(String resource) {
		this.resource = resource;
	}

	public int getCounter() {
		return counter;
	}

	public void setCounter(int counter) {
		this.counter = counter;
	}
	
	public void incrementCounter() {
		counter++;
	}
	
	public static Resource getMostRequestedResource(HashMap resources) {
		Iterator it = resources.entrySet().iterator();
		Resource res = null;
		int most = 0;
	    while (it.hasNext()) {
	        Map.Entry entry = (Map.Entry)it.next();
	        Resource resource = (Resource)entry.getValue();
	        if(most < resource.getCounter()) {
	        	res = resource;
	        	most = resource.getCounter();
	        }
	    }
	    return res;
	}
}
